﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DatabaseExtension
{
    /// <summary>
    /// Vital point of query builder.
    /// </summary>
    public interface IQueryBuilder
    {
        /// <summary>
        /// If top was set by user, set Limitation for query.
        /// </summary>
        /// <param name="limitation">limit rows of the output.</param>
        /// <returns>IQueryBuilder</returns>
        IQueryBuilder Top(Int64 limitation);
        /// <summary>
        /// Declare distinct columns
        /// </summary>
        /// <param name="def">column(s) definition</param>
        /// <returns>IQueryBuilder</returns>
        IQueryBuilder Distinct(String def);
        /// <summary>
        /// Declare column for default selection.
        /// </summary>
        /// <param name="def">column(s) definition.</param>
        /// <returns>IQueryBuilder</returns>
        IQueryBuilder Select(String def);
        /// <summary>
        /// Set table Name, without database and schema.
        /// </summary>
        /// <param name="table">Table name</param>
        /// <returns>IQueryBuilder</returns>
        IQueryBuilder From(String table);
        /// <summary>
        /// Set table schema and name, without database.
        /// </summary>
        /// <param name="schema">schema name</param>
        /// <param name="table">table name</param>
        /// <returns>IQueryBuilder</returns>
        IQueryBuilder From(String schema, String table);
        /// <summary>
        /// Set table database, schema and name-
        /// </summary>
        /// <param name="database">database name</param>
        /// <param name="schema">schema name</param>
        /// <param name="table">table name</param>
        /// <returns>IQueryBuilder</returns>
        IQueryBuilder From(String database, String schema, String table);
        /// <summary>
        /// Define query filter
        /// </summary>
        /// <param name="def">where filter definition</param>
        /// <returns>IQueryBuilder</returns>
        IQueryBuilder Where(String def);
        /// <summary>
        /// define group by columns
        /// </summary>
        /// <param name="def">group by columns definition</param>
        /// <returns>IQueryBuilder</returns>
        IQueryBuilder GroupBy(String def);
        /// <summary>
        /// define order by columns
        /// </summary>
        /// <param name="def">order by columns definition</param>
        /// <returns>IQueryBuilder</returns>
        IQueryBuilder OrderBy(String def);
        /// <summary>
        /// start new query for union select
        /// </summary>
        /// <returns>IQueryBuilder</returns>
        IQueryBuilder BeginUnion();
        /// <summary>
        /// end union select
        /// </summary>
        /// <returns>IQueryBuilder</returns>
        IQueryBuilder EndUnion();
        /// <summary>
        /// Start new Query for union all select
        /// </summary>
        /// <returns>IQueryBuilder</returns>
        IQueryBuilder UnionAll();
        /// <summary>
        /// End union all select
        /// </summary>
        /// <returns>IQueryBuilder</returns>
        IQueryBuilder EndUnionAll();
        /// <summary>
        /// Get full query.
        /// </summary>
        String Query { get; }
    }
}
